# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import sqlite3
from bottle import route, run

def init():
    conn = sqlite3.connect("todo.db")
    conn.execute("CREATE TABLE todo (id INTEGER PRIMARY KEY,task char(100) NOT NULL,status bool NOT NULL)")
    conn.execute("INSERT INTO todo(task,status) VALUES('学习python的流水线',0)")
    conn.execute("INSERT INTO todo(task,status) VALUES('测试python的流水线',1)")
    conn.commit()


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.

@route('/todo')
def todo_list():
    conn = sqlite3.connect('todo.db')
    c = conn.cursor()
    c.execute("SELECT id,task FROM todo WHERE status LIKE '1'")
    result = c.fetchall()
    return str(result)

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    # init()
    run(reload=True, host='localhost', port=8888)

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
